<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <!--
  XSD Model of a poker hand history for the three major "flop" games:
  Texas Hold'em, Omaha Hi, and Omaha Hi/Lo.  The three major betting
  types (limit, pot-limit, and no-limit) are supported.
 
  Copyright (C) 2007 Wesley Tansey.
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  -->
  <xs:element name="PokerHandXML" type="PokerHandXML"/>
  <xs:complexType name="PokerHandXML">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="Hands" type="PokerHand"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="PokerHand">
    <xs:sequence>
      <xs:sequence id="Blinds" minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Blinds" type="Blind" />
      </xs:sequence>
      <xs:sequence id="HoleCards" minOccurs="0" maxOccurs="unbounded">
        <xs:element name="HoleCards" type="Card" />
      </xs:sequence>
      <xs:sequence minOccurs="1" maxOccurs="5">
        <xs:element name="Rounds" type="Round" />
      </xs:sequence>
      <xs:element name="Context" type="Context" nillable="false" />
      <xs:sequence minOccurs="1" maxOccurs="unbounded">
        <xs:element name="Results" type="HandResult"  />
      </xs:sequence>
      <xs:sequence minOccurs="1" maxOccurs="unbounded">
        <xs:element name="Players" type="Player" />
      </xs:sequence>
      <xs:element name="Rake" type="Amount"/>
      <xs:element name="Hero" type="xs:string" />
    </xs:sequence>
    
  </xs:complexType>

  <xs:simpleType name="PokerVariant">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="TexasHoldEm" />
      <xs:enumeration value="OmahaHi" />
      <xs:enumeration value="OmahaHiLo" />
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="Amount">
    <xs:restriction base="xs:decimal">
      <xs:fractionDigits value="2"/>
      <xs:minInclusive value="0.00"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="BettingType">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="FixedLimit" />
      <xs:enumeration value="PotLimit" />
      <xs:enumeration value="NoLimit" />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="Context">
    <xs:attribute name="Online" type="xs:boolean" default="true" />
    <xs:attribute name="Site" type="xs:string" />
    
    <xs:attribute name="ID" type="xs:ID" use="required" />
    <xs:attribute name="Table" type="xs:string" use="required"/>
    <xs:attribute name="TimeStamp" type="xs:dateTime" use="required" />

    <xs:attribute name="Format" type="GameFormat" use="required" />
    <xs:attribute name="Button" type="xs:int" use="required" />

    <!-- Betting info about the game -->
    <xs:attribute name="BigBlind" type="Amount" use="required" />
    <xs:attribute name="SmallBlind" type="Amount" use="required" />
    <xs:attribute name="Ante" type="Amount" default="0.00" />
    <xs:attribute name="BettingType" type="BettingType" use="required" />
    <xs:attribute name="Capped" type="xs:boolean" default="false" />
    <xs:attribute name="CapAmount" type="Amount" use ="optional"/>

    <xs:attribute name="PokerVariant" type="PokerVariant" use="required"/>
  </xs:complexType>

  <xs:simpleType name="GameFormat">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="CashGame" />
      <xs:enumeration value="SitNGo" />
      <xs:enumeration value="MultiTableTournament" />
    </xs:restriction>
  </xs:simpleType>
  
  <xs:complexType name="Player">
    <xs:attribute name="Name" type="xs:string" use="required" />
    <xs:attribute name="Stack" type="Amount" use="required" />
    <xs:attribute name="Seat" type="xs:int" use="required" />
  </xs:complexType>

  <xs:complexType name="Blind">
    <xs:attribute name="Player" type="xs:string" />
    <xs:attribute name="Type" type="BlindType" default="None"/>
    <xs:attribute name="Amount" type="Amount" default="0.00"/>
    <xs:attribute name="AllIn" type="xs:boolean"  default="false" />
  </xs:complexType>

  <xs:simpleType name="BlindType">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="None" />
      <xs:enumeration value="Ante" />
      <xs:enumeration value="SmallBlind" />
      <xs:enumeration value="BigBlind" />
      <xs:enumeration value="LateBlind" />
      <xs:enumeration value="DeadBlind" />
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="Round">
    <xs:sequence>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element name="CommunityCards" type="Card" />
      </xs:sequence>
      <xs:sequence id="Actions" minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Actions" type="Action" />
      </xs:sequence>
    </xs:sequence>
  </xs:complexType>


  <xs:simpleType name="RoundName">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="Preflop"/>
      <xs:enumeration value="Flop"/>
      <xs:enumeration value="Turn"/>
      <xs:enumeration value="River"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="Card">
    <xs:attribute name="Rank" type="Rank" use="required"/>
    <xs:attribute name="Suit" type="Suit" use="required"/>
  </xs:complexType>

  <xs:simpleType name="Rank">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="None"/>
      <xs:enumeration value="Two"/>
      <xs:enumeration value="Three"/>
      <xs:enumeration value="Four"/>
      <xs:enumeration value="Five"/>
      <xs:enumeration value="Six"/>
      <xs:enumeration value="Seven"/>
      <xs:enumeration value="Eight"/>
      <xs:enumeration value="Nine"/>
      <xs:enumeration value="Ten"/>
      <xs:enumeration value="Jack"/>
      <xs:enumeration value="Queen"/>
      <xs:enumeration value="King"/>
      <xs:enumeration value="Ace"/>
      <xs:enumeration value="Joker"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="Suit">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="None" />
      <xs:enumeration value="Clubs"/>
      <xs:enumeration value="Diamonds"/>
      <xs:enumeration value="Hearts"/>
      <xs:enumeration value="Spades"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="ActionType">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="None" />
      <xs:enumeration value="Fold" />
      <xs:enumeration value="Check" />
      <xs:enumeration value="Call" />
      <xs:enumeration value="Bet" />
      <xs:enumeration value="Raise" />
      <xs:enumeration value="Returned" />
    </xs:restriction>
  </xs:simpleType>

  <!--
  <xs:complexType name="Action">
    <xs:sequence>
      <xs:element name="Player" type="xs:string" />
      <xs:element name="Type" type="ActionType" />
      <xs:element name="Amount" type="Amount" default="0.00"/>
      <xs:element name="AllIn" type="xs:boolean"  default="false" />
    </xs:sequence>
  </xs:complexType>
-->

  <xs:complexType name="Action">

    <xs:attribute name="Player" type="xs:string" />
    <xs:attribute name="Type" type="ActionType" default="None" />
    <xs:attribute name="Amount" type="Amount" default="0.00"/>
    <xs:attribute name="AllIn" type="xs:boolean"  default="false" />
    
  </xs:complexType>
  
  <!-- Don't really care about chat
  <xs:complexType name="chat">
    <xs:attribute name="playerid" type="xs:string"/>
  </xs:complexType>
  -->


  <xs:complexType name="HandResult">
    <xs:sequence>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element name="HoleCards" type="Card"  />
      </xs:sequence>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element name="WonPots" type="Pot" />
      </xs:sequence>
    </xs:sequence>
    <xs:attribute name="Player" type="xs:string" use="required" />
  </xs:complexType>
  
  <xs:complexType name="Pot">
    <xs:attribute name="Amount" type="Amount" default="0.00" />
    <xs:attribute name="Number" type="xs:int" default="0" />
  </xs:complexType>
</xs:schema>
